﻿namespace Smark.Core
{
    using System;
    using System.Collections;
    using System.Collections.Specialized;
    using System.Reflection;

    public class KeyValueCollection<T> : NameObjectCollectionBase
    {
        public KeyValueCollection()
        {
        }

        public KeyValueCollection(IDictionary d, bool bReadOnly)
        {
            foreach (DictionaryEntry entry in d)
            {
                base.BaseAdd((string) entry.Key, entry.Value);
            }
            base.IsReadOnly = bReadOnly;
        }

        public void Add(string key, T value)
        {
            base.BaseAdd(key, value);
        }

        public void Clear()
        {
            base.BaseClear();
        }

        public void Remove(int index)
        {
            base.BaseRemoveAt(index);
        }

        public void Remove(string key)
        {
            base.BaseRemove(key);
        }

        public string[] AllKeys
        {
            get
            {
                return base.BaseGetAllKeys();
            }
        }

        public Array AllValues
        {
            get
            {
                return base.BaseGetAllValues();
            }
        }

        public bool HasKeys
        {
            get
            {
                return base.BaseHasKeys();
            }
        }

        public T this[string key]
        {
            get
            {
                return (T) base.BaseGet(key);
            }
            set
            {
                base.BaseSet(key, value);
            }
        }

        public DictionaryEntry this[int index]
        {
            get
            {
                return new DictionaryEntry(base.BaseGetKey(index), base.BaseGet(index));
            }
        }
    }
}

